import request from "@/utils/request";

// 获取sku图片列表
export const apiGetSkuImgList = (spuId)=>request.get(`/admin/product/spuImageList/${spuId}`)

// 获取sku销售属性
export const apiGetSkuSaleAttr = (spuId) => request.get(`/admin/product/spuSaleAttrList/${spuId}`)

// 添加sku
export const apiSaveSku = (skuInfo) => request.post(`/admin/product/saveSkuInfo`, skuInfo)

// 通过spuId获取sku的数据
export const apiGetSkuList = (spuId)=> request.get(`/admin/product/findBySpuId/${spuId}`)

// 获取sku基础的数据 /admin/product/list/{page}/{limit}
export const apiGetSkuBaseList = ({page,limit})=> request.get(`/admin/product/list/${page}/${limit}`)

// 商品上架和下架操作， type onSale 上架 cancelSale 下架
export const apiChangeSaleState = (skuId, type) =>{
  if(type === 'onSale') {
    return request.get(`/admin/product/onSale/${skuId}`) // 上
  }else {
    return request.get(`/admin/product/cancelSale/${skuId}`) // 下
  }
}

// 通过sku的id获取sku的数据
export const apiGetSkuInfoById = (skuId) => request.get(`/admin/product/getSkuById/${skuId}`)
